<?php
session_start();
//连接到数据库
include ('../config.php');

//$sql="SELECT *FROM admin";
//$mysql_result=$mysql->query($sql);
//$row=$mysql_result->fetch_array(MYSQLI_ASSOC);

if( $input->get('act')=='chk'){
    $user=$input->post('auser');
    $pass=$input->post('apass');
    $sql="SELECT *FROM admin WHERE auser='{$user}' AND apass='{$pass}'";
    $mysql_result=$db->query($sql);
    $row=$mysql_result->fetch_array(MYSQLI_ASSOC);
    if(is_array($row)){                                                 // is_array()..检测变量是否是数组
        $_SESSION['aid']=$row['aid'];
        header('location:home.php');
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>管理员登录</title>
    <?php include (PATH.'/header.inc.php'); ?>
</head>
<body>
    <div class="container">
        <div class="col-md-6 col-md-offset-3" style="margin-top: 200px">
            <div class="panel panel-primary">
                <div class="panel-heading" >管理员登录</div>
                <div class="panel-body">
                    <form class="form-horizontal" action="login.php?act=chk" method="post">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">用户：</label>
                            <div class="col-sm-10">
                                <input type="text" name="auser" class="form-control" id="auser" placeholder="请输入用户名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">密码：</label>
                            <div class="col-sm-10">
                                <input type="password" name="apass" class="form-control" id="apass" placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary">提交登录</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="panel-footer text-right">所有权版属于我</div>
            </div>
        </div>
    </div>
</body>
</html>